/**
 * @file Assignment_B.cpp
 * @brief 
 * @author htli (3180102114@zju.edu.cn)
 * @version 1.0
 * @date 2021-10-03
 * 
 * @copyright Copyright (c) 2021  linhuo2020
 * 
 */
#include "BisectionSolver.h"
double f1(const double x)
{
    return 1.0 / x - tan(x);
};
double f2(const double x)
{
    return 1.0 / x - pow(2, x);
};
double f3(const double x)
{
    return pow(2, -x) + exp(x) + 2 * cos(x) - 6;
};
double f4(const double x)
{
    double x2 = x * x;
    double x3 = x2 * x;
    return (x3 + 4 * x2 + 3 * x + 5) / (2 * x3 - 9 * x2 + 18 * x - 2);
};

int main()
{
    BisectionSolver A;
    A.set_max_iteration(500);
    A.set_tolerance(1e-8);

    std::cout << "B.1" << std::endl;
    A.set_pf(f1);
    A.set_init(0, M_PI / 2.0);
    A.solve();

    std::cout << "B.2" << std::endl;
    A.set_pf(f2);
    A.set_init(0, 1);
    A.solve();

    std::cout << "B.3" << std::endl;
    A.set_pf(f3);
    A.set_init(1, 3);
    A.solve();

    std::cout << "B.4" << std::endl;
    A.set_pf(f4);
    A.set_init(0, 4);
    A.solve();
};